Page({
  data: {
    questions: [],
    totalFalse:0,
    totalCount:0,
    totalScore:0,
    getScore:0
  },
  onLoad: function (options) {
    var self = this
    try {
      var value = wx.getStorageSync('questions')
      if (value) {
       self.setData({
         questions:value
       })
      }
    } catch (e) {
      console.log('获取数据失败');
    }
  },
  onReady: function () {

    let  total_false = 0,total_num = 0, total_score = 0, get_score = 0,
    str = this.data.questions;
    
    
    //错题数组
    let false_questions = [];  

    //计算分数工程
    for (let item in str) {
      
      total_num++;
      total_score += 5;
      // console.log(str[item].options[str[item].userchoose].key)
      if (str[item].options[str[item].userchoose].key=='true') {
        get_score += 5;
      }else {
        total_false ++;
        false_questions.push(str[item]);
      }
    }
    try{
      wx.setStorageSync('false_questions', false_questions);
    }catch(e){
      console.log(e.message);
    }
    console.log(false_questions);
    

    this.setData({
      totalFalse: total_false,
      totalCount: total_num,
      totalScore: total_score,
      getScore: get_score
    })

  },

  check: function(e){
    wx.redirectTo({
      url: '../false/false',
    })
  },
  back: function(e){
    console.log('返回');
    wx.navigateBack({
      url: '../index/index',
    })
  }
    
})
  
 